home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4721 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Compiler error on long multiplication?
  5. Date: Tue, 06 Feb 96 15:47:49 GMT
  6. Organization: none
  7. Message-ID: <823621669snz@genesis.demon.co.uk>
  8. References: <4f4fr0$pea@newnews.iafrica.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4f4fr0$pea@newnews.iafrica.com>
  15.            vizier@iafrica.com "Pieter Malan" writes:
  16.  
  17. >This code was compiled with 3.1.  When compiled for 80386, the 
  18. >one onswer is wrong as indicated.  For all other processors the 
  19. >answer is correct.  WHY??
  20. >
  21. >void main()
  22.  
  23. In C main returns int. By declaring it as returning void here you absolve
  24. the compiler of all responsibility for compiling your code in any sensible
  25. way.
  26.  
  27. >{
  28. >unsigned long a;  //OR SIGNED
  29.  
  30. Also please post to comp.lang.c code that people with C compilers can
  31. compile. In C comments are delimited by /* and */; // is a syntax error.
  32.  
  33. >unsigned long x;
  34. >
  35. >        a = 1;
  36. >        x = (a * 100L) * 100L;  // x = 13379344 WRONG!!!
  37. >        a = 100;
  38. >        x = a * 100L;           // x = 10000
  39. >
  40. >}
  41.  
  42. This code doesn't print any answer. You should post the actual code you
  43. used to print the answer since the problem might be in how you printed it.
  44. There is nothing wrong with the expressions given. Maybe Borland have
  45. more work to do on their 80386 code generator but that's can't be determined
  46. without knowing the exact program you used to generate the output.
  47.  
  48. It is interesting to note that 13379344 & 0xffff is 10000
  49.  
  50. -- 
  51. -----------------------------------------
  52. Lawrence Kirby | fred@genesis.demon.co.uk
  53. Wilts, England | 70734.126@compuserve.com
  54. -----------------------------------------
  55.